package Callable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author czl
 * @Date 2024-03-19
 */
public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyClallable myClallable = new MyClallable();

        FutureTask<Integer> futureTask =new FutureTask<>(myClallable);
        FutureTask<Integer> futureTask1 =new FutureTask<>(myClallable);
        FutureTask<Integer> futureTask2 =new FutureTask<>(myClallable);

        Thread thread = new Thread(futureTask);
        Thread thread1 = new Thread(futureTask1);
        Thread thread2 = new Thread(futureTask2);

        thread.start();
        thread1.start();
        thread2.start();

        Integer result = futureTask.get();
        Integer result1 = futureTask1.get();
        Integer result2 = futureTask2.get();

        System.out.println(result+ "是:红"+ "    "+ result1+"是:蓝" +"    "+ result2+ "是:绿");

    }
}
